home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Windows 95 API Bible
/
Windows 95 API Bible 3 Disc Set.iso
/
Win32 API Bible Book 1 of 3
/
CHAPTE21
/
EX9.C
< prev
next >
Wrap
C/C++ Source or Header
|
1995-05-29
|
2KB
|
51 lines
#include <genstub.c>
LRESULT CALLBACK WndProc(HWND hWnd, UINT uMsg, WPARAM wParam, LPARAM lParam)
{
static DWORD rgbIniActiveCaption;
static DWORD rgbIniInactiveCaption;
switch (uMsg)
{
case WM_CREATE: // store initial values of colors
rgbIniActiveCaption = GetSysColor( COLOR_ACTIVECAPTION );
rgbIniInactiveCaption = GetSysColor( COLOR_INACTIVECAPTION );
return (DefWindowProc(hWnd, uMsg, wParam, lParam));
case WM_COMMAND:
switch ( LOWORD( wParam ) )
{
case IDM_TEST:
{
DWORD rgbs[2]; // new color values
UINT dispEls[2]; // elements affected
rgbs[0] = RGB( 255, 0, 0 ); // RED
dispEls[0] = COLOR_ACTIVECAPTION;
rgbs[1] = RGB( 0, 255, 0 ); // GREEN
dispEls[1] = COLOR_INACTIVECAPTION;
SetSysColors( 2, &dispEls, &rgbs );
}
break;
case IDM_EXIT:
DestroyWindow( hWnd );
break;
}
break;
case WM_DESTROY:
{ // Return colors to stored initial values.
DWORD rgbs[2];
UINT dispEls[2];
rgbs[0] = rgbIniActiveCaption;
dispEls[0] = COLOR_ACTIVECAPTION;
rgbs[1] = rgbIniInactiveCaption;
dispEls[1] = COLOR_INACTIVECAPTION;
SetSysColors( 2, &dispEls, &rgbs );
PostQuitMessage( 0 );
}
break;
default:
return (DefWindowProc(hWnd, uMsg, wParam, lParam));
}
return (NULL);
}